package com.zr.controller;

import com.zr.common.emailUtil.SendEmailUtil;
import com.zr.dto.staff.StaffDetailInfoRequest;
import com.zr.entity.Staff;
import com.zr.pojo.Result;
import com.zr.service.SendEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @create
 */
@RestController
@CrossOrigin
@RequestMapping("/sendEmail")
public class SendEmailController {

    @Autowired
    private SendEmailService sendEmailService;

    /***
     * 发送邮件
     * @param staffDetailInfoRequest
     * @return
     */
    @PostMapping("/send")
    public Result sendEmail(@RequestBody StaffDetailInfoRequest staffDetailInfoRequest){
        Staff staffInfo = sendEmailService.getEmailInfoById(staffDetailInfoRequest);
//        staffInfo.setUserEmail("740498917@qq.com");
        SendEmailUtil.sendEmail("smtp.qq.com", "587", "740498917@qq.com",
                "xjxwbduvescubeib", staffInfo.getUserEmail(), "系统邮件测试",
                "******审批流程 已审核!", "2");
//        EmailResponse response = new EmailResponse("200","success");
        return Result.success("邮件发送成功");

    }
}
